package cn.edu.zsc.blms.model;

import cn.edu.zsc.blms.domain.BaseEntity;
import cn.edu.zsc.blms.domain.Book;
import cn.edu.zsc.blms.domain.Reader;
import cn.edu.zsc.blms.util.DateUtil;

import java.util.Date;

public class Borrowing extends BaseEntity {
    public static int idCounter = 0;
    public Reader reader;
    public Book book;
    public Date borrowTime, returnTime;
    public Borrowing(){}
    public Borrowing(Reader reader, Book book, Date borrowTime){
        this.id = book.id;
        this.reader = reader;
        this.book = book;
        this.borrowTime = borrowTime;
    }
    @Override
    public String toString(){
        return "ID: " + id + ", 读者姓名: " + reader.name + ", 图书名称: " + book.name + ", 借出时间: " + DateUtil.formatDate(borrowTime) + ", 归还时间: " + (returnTime == null ? "" : DateUtil.formatDate(returnTime));
    }
}
